package com.distribute.framework.model;

import com.distribute.framework.core.web.helper.Utils;
import java.lang.reflect.Field;
import java.util.Date; 
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;

import javax.annotation.Resource;

import com.distribute.framework.core.web.util.Page;
import com.distribute.framework.core.lang.*; 
import com.distribute.framework.core.web.helper.WebHelper.LzMap;
import com.distribute.framework.core.util.Function;
import com.distribute.framework.core.util.IbatisMap;
import com.distribute.framework.config.*;
import com.distribute.framework.plugin.*;

@namespace("users/useraddress")
public @caption("收货地址") @database(DatabaseNames.distribute_sys) @source("distribute_sys") @table("user_address") class UserAddress implements java.io.Serializable
{
	private static final long serialVersionUID = 1l;
	private @caption("编号") @column("id")    @primary  @notnull  @note("  ") Long id;// 主键 非空     
	private @caption("会员信息") @column("member")      @relate("$member") @RelateClass(Member.class)  @note("  ") Long member;//     
 	private transient Member $member;//关联对象[会员信息]
	private @caption("电话号码") @column("mobile")      @note("  ") String mobile;//     
	private @caption("收货姓名") @column("real_name")      @note("  ") String realName;//     
	private @caption("性别") @column("sex")      @note(" 1:男 2:女  ") Short sex;// 1:男 2:女     
	private @caption("默认") @column("is_default")      @note(" 0:否 1:默认  ") Short isDefault;// 0:否 1:默认     
	private @caption("地址") @column("address")      @relate("$address") @RelateClass(Region.class)  @note("  ") Long address;//     
 	private transient Region $address;//关联对象[省市地区]
	private @caption("详细地址") @column("detail_address")      @note("  ") String detailAddress;//     
	private @caption("所属城市") @column("city_origin")      @relate("$cityOrigin") @RelateClass(Region.class)  @note("  ") Long cityOrigin;//     
 	private transient Region $cityOrigin;//关联对象[省市地区]
	private @caption("地址全称") @column("full_address") @like  @hidden    @note("  ") String fullAddress;//     
	private @caption("经度") @column("longitude")      @note("  ") String longitude;//     
	private @caption("纬度") @column("latitude")      @note("  ") String latitude;//     
	private @caption("坐标地址") @column("coordinate")      @note("  ") String coordinate;//     
	 
	//默认构造函数
	public UserAddress(){ 
	
	}
	
	//主键构造函数
	public UserAddress(Long id){
		this.id = id;
	}
	
	/**所有字段构造函数 
	 UserAddress(
	 	Utils.getLong("member")//会员信息
	 	,Utils.getString("mobile")//电话号码
	 	,Utils.getString("realName")//收货姓名
	 	,Utils.getShort("sex")//性别
	 	,Utils.getShort("isDefault")//默认
	 	,Utils.getLong("address")//地址
	 	,Utils.getString("detailAddress")//详细地址
	 	,Utils.getLong("cityOrigin")//所属城市
	 	,Utils.getString("fullAddress")//地址全称
	 	,Utils.getString("longitude")//经度
	 	,Utils.getString("latitude")//纬度
	 	,Utils.getString("coordinate")//坐标地址
	 )
	**/
	public UserAddress(Long member,String mobile,String realName,Short sex,Short isDefault,Long address,String detailAddress,Long cityOrigin,String fullAddress,String longitude,String latitude,String coordinate){
		this.member=member;
		this.mobile=mobile;
		this.realName=realName;
		this.sex=sex;
		this.isDefault=isDefault;
		this.address=address;
		this.detailAddress=detailAddress;
		this.cityOrigin=cityOrigin;
		this.fullAddress=fullAddress;
		this.longitude=longitude;
		this.latitude=latitude;
		this.coordinate=coordinate;
	}
	
	//设置非空字段
	public UserAddress setNotNull(){
		return this;
	}
	/** 编号 [非空]       **/
	public UserAddress id(Long id){
		this.id = id;
		this.setSeted(F.id);
		return this;
	}
	/** 会员信息  [Member]      **/
	public UserAddress member(Long member){
		this.member = member;
		this.setSeted(F.member);
		return this;
	}
	/** 电话号码        **/
	public UserAddress mobile(String mobile){
		this.mobile = mobile;
		this.setSeted(F.mobile);
		return this;
	}
	/** 收货姓名        **/
	public UserAddress realName(String realName){
		this.realName = realName;
		this.setSeted(F.realName);
		return this;
	}
	/** 性别    1:男 2:女     **/
	public UserAddress sex(Short sex){
		this.sex = sex;
		this.setSeted(F.sex);
		return this;
	}
	/** 默认    0:否 1:默认     **/
	public UserAddress isDefault(Short isDefault){
		this.isDefault = isDefault;
		this.setSeted(F.isDefault);
		return this;
	}
	/** 地址  [Region]      **/
	public UserAddress address(Long address){
		this.address = address;
		this.setSeted(F.address);
		return this;
	}
	/** 详细地址        **/
	public UserAddress detailAddress(String detailAddress){
		this.detailAddress = detailAddress;
		this.setSeted(F.detailAddress);
		return this;
	}
	/** 所属城市  [Region]      **/
	public UserAddress cityOrigin(Long cityOrigin){
		this.cityOrigin = cityOrigin;
		this.setSeted(F.cityOrigin);
		return this;
	}
	/** 地址全称        **/
	public UserAddress fullAddress(String fullAddress){
		this.fullAddress = fullAddress;
		this.setSeted(F.fullAddress);
		return this;
	}
	/** 经度        **/
	public UserAddress longitude(String longitude){
		this.longitude = longitude;
		this.setSeted(F.longitude);
		return this;
	}
	/** 纬度        **/
	public UserAddress latitude(String latitude){
		this.latitude = latitude;
		this.setSeted(F.latitude);
		return this;
	}
	/** 坐标地址        **/
	public UserAddress coordinate(String coordinate){
		this.coordinate = coordinate;
		this.setSeted(F.coordinate);
		return this;
	}
	
	
	/**
	* 克隆对象
	**/
	public UserAddress clone(){
		UserAddress clone = new UserAddress();
		clone.member=this.member;
		clone.mobile=this.mobile;
		clone.realName=this.realName;
		clone.sex=this.sex;
		clone.isDefault=this.isDefault;
		clone.address=this.address;
		clone.detailAddress=this.detailAddress;
		clone.cityOrigin=this.cityOrigin;
		clone.fullAddress=this.fullAddress;
		clone.longitude=this.longitude;
		clone.latitude=this.latitude;
		clone.coordinate=this.coordinate;
		return clone;
	}
	
	
	/**
	 * 根据ID取收货地址
	 * @param id
	 * @return
	 */
	public static @api UserAddress get(Long id){		
		return getUserAddressById(id);
	}
	
	/**
	 * 获取所有收货地址
	 * @return
	 */
	public static @api List<UserAddress> list(Map params,Integer size){
		return getUserAddressList(params,size);
	}
	/**
	 * 获取收货地址分页
	 * @return
	 */
	public static @api Page<UserAddress> page(Integer page,Integer size,Map params){
		return getUserAddressPage(page, size , params);
	}
	
	
	/**
	 * 根据查询条件取收货地址
	 * @param params
	 * @return
	 */
	public static @api UserAddress Get(Map params){
		return getUserAddress(params);
	}
	/**
	 * 获取收货地址数
	 * @return
	 */
	public static @api Long count(Map params){
		return getUserAddressCount(params);
	}
	/**
	 * 获取收货地址数
	 * @return
	 */
	public static @api <T> T eval(String eval,Map params){
		return getUserAddressEval(eval,params);
	}
	/**
	 * 获取收货地址图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey){
		return getUserAddressStats(params,sumKey,groupKey,-1);
	}
	/**
	 * 获取收货地址图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> stats(Map params,C sumKey,C groupKey,int dateType){
		return getUserAddressStats(params,sumKey,groupKey,dateType);
	}
	
	/**
	 * 根据ID取收货地址
	 * @param id
	 * @return
	 */
	public static @api UserAddress getUserAddressById(Long id){		
		return getUserAddressDao().getUserAddressById(id);
	}
	
	
	/**
	 * 根据ID取收货地址的标识键值
	 * @param id
	 * @return
	 */
	public static @api String getKeyValue(Object key){
		Long id = Utils.parseLong(key);	
		if(id==null || id.longValue()==0 ){
			return null;
		}
		String value = null;
		if(value==null){
			UserAddress userAddress = get(id);
			if(userAddress!=null){
				String strValue = userAddress.getId$();
				value = strValue;
			}else{
				value = "{"+id+"}";
			}
		}
		/************LAZY3Q_ID_KEYVALUE************/
		/************LAZY3Q_ID_KEYVALUE************/
		return value;
	}	
	
	
	/**
	 * 获取当前对象的键值
	 * @return
	 */
	public String getKeyValue(){
		/************LAZY3Q_CODE_KEYVALUE************/
		/************LAZY3Q_CODE_KEYVALUE************/
		String keyValue = this.getId$();
		return keyValue;
	}
	
	
	/**
	 * 根据关键字精确查询收货地址对象
	 * @return
	 */
	public static @api UserAddress find(String key){
		if(Utils.empty(key))return null;
		Map params = new HashMap();
		if(key.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
			params.put("id", key.toLowerCase().replaceFirst("id:", ""));					
		else{//按标识查询，精确查询
			String strDefinex = "";
			strDefinex="(2=1 "+strDefinex+")";
			params.put("definex",strDefinex);
		}
		/************LAZY3Q_CODE_FIND************/
		/************LAZY3Q_CODE_FIND************/
		return UserAddress.getUserAddress(params);
	}
	
	
	/**
	 * 根据关键字查询收货地址
	 * @return
	 */
	public static @api List<Map> query(String key,int size,Map params,Boolean bObject){
		if(Utils.empty((String)params.get("asc")) && Utils.empty((String)params.get("desc")))//如果未传入排序字段
			params.put("desc","id");//那么，默认以主键降序，传给Dao层
		String strTerm=key;		
		if(!Utils.empty(strTerm)){
			if(strTerm.toLowerCase().startsWith("id:"))//如果查询条件以id:开头，则按ID查询
				params.put("id", strTerm.toLowerCase().replaceFirst("id:", ""));					
			else//按标识查询，模糊查询请带%
			{
				String strDefinex = "";
				strDefinex="(2=1 "+strDefinex+")";
				params.put("definex",strDefinex);
			}
		}
		/************LAZY3Q_CODE_QUERY************/
		/************LAZY3Q_CODE_QUERY************/
			
		List<UserAddress> list = page(0,size,params).getResult();
		
		/**
		* OK!取到数据拼成放入Map中，[{value,text,object:{...}},...]
		* value:数据ID，text:数据标识,object,整个对象
		**/
		List<Map> result = new java.util.ArrayList();
		for(UserAddress userAddress:list){
			Map map = new HashMap();
			map.put("key",userAddress.getId().toString());
			map.put("value", Utils.js(userAddress.getKeyValue()));
			if(bObject==true)
				map.put("object",userAddress);
			result.add(map);
		}
		/************LAZY3Q_AFTER_QUERY************/
		/************LAZY3Q_AFTER_QUERY************/
		
		return result;
	}
	
	
	
	/**
	 * 获取所有收货地址
	 * @return
	 */
	public static @api List<UserAddress> getUserAddressList(Map params,Integer size){
		return getUserAddressDao().getUserAddressList(params,0,size);
	}
	
	/**
	 * 获取收货地址分页
	 * @return
	 */
	public static @api Page<UserAddress> getUserAddressPage(Integer page,Integer size,Map params){
		if(page==null)page=0;
		if(size==null)size=20;
		return getUserAddressDao().getUserAddressPage(page, size , params);
	}
	
	/**
	 * 根据查询条件取收货地址
	 * @param params
	 * @return
	 */
	public static @api UserAddress getUserAddress(Map params){
		return getUserAddressDao().getUserAddress(params);
	}
	
	/**
	 * 保存一个收货地址
	 * @param userAddress
	 * @return
	 */
	public static @api UserAddress saveUserAddress(UserAddress userAddress){
		return getUserAddressDao().saveUserAddress(userAddress);
	}
	
	/**
	 * 根据条件更新收货地址
	 * @param values
	 * @param params
	 */
	public static @api int updateUserAddressByConfirm(Map values, Map params){
		return getUserAddressDao().updateUserAddressByConfirm(values,params);
	}
	
	/**
	 * 修改一个收货地址
	 * @param userAddress
	 * @return
	 */
	public static @api int updateUserAddress(UserAddress userAddress){
		return getUserAddressDao().updateUserAddress(userAddress);
	}
	
	/**
	 * 更新收货地址非空字段
	 * @param userAddress
	 */
	public static @api int updateUserAddress$NotNull(UserAddress userAddress){
		return getUserAddressDao().updateUserAddress$NotNull(userAddress);
	}
	
	/**
	 * 获取收货地址数
	 * @return
	 */
	public static @api Long getUserAddressCount(Map params){
		return getUserAddressDao().getUserAddressCount(params);
	}
		
		
	/**
	 * 获取收货地址自定义求和表达式,比如求和:eval="sum(id)"
	 * @return
	 */	
	public static @api <T> T getUserAddressEval(String eval,Map params){
		return getUserAddressDao().getUserAddressEval(eval,params);
	}
	/**
	 * 获取收货地址图表统计数据
	 * @param params 查询条件
	 * @param sumKey 统计的字段
	 * @param groupKey 分组的字段
	 * @param dateType 1:按年， 2：按月， 3：按周， 4：按日， 5：按小时， 6：月分， 7：日分， 8：点分
	 * @return
	 */
	public static @api List<Map> getUserAddressStats(Map params,C sumKey,C groupKey,int dateType){
		//TODO:图表统计功能未实现
		
		Map<String,Object> groups=new HashMap();//要分组的字段
		Map<String,Object> sums=new HashMap();//要统计的字段
		
		String[][] dateFormats=new String[][]{
				null,
				new String[]{"%Y","yyyy年","Y"},
				new String[]{"%Y-%m","yyyy年MM月","M"},
				new String[]{"%Y%U","yyyy年第ww周","W"},
				new String[]{"%Y-%m-%d","yyyy年MM月dd日","D"},
				new String[]{"%Y-%m-%d %H","yyyy年MM月dd日 HH点","H"},
				new String[]{"%m","MM月"},
				new String[]{"%d","dd号"},
				new String[]{"%H","HH点"} 
		};
		
		//获取要分组的字段，放入Map中
		if(dateType>0){
			groups.put(groupKey.toString(),"DATE_FORMAT({key},'"+dateFormats[dateType][0]+"')");
		}else{
			groups.put(groupKey.toString(),"{key}");
		}
		if(dateType<6 && dateType>0){ 
			params.put("asc", groupKey.toString()); 
			if(params.get(groupKey.name()+"Start")==null){
				params.put(groupKey.name()+"Start", Utils.date(new Date(), -24, dateFormats[dateType][2]));
			}
		}
		
		
		//获取要统计的字段，放入Map中
		if(sumKey.toString().equals("count")){
			sums.put(sumKey.toString(),"count(*)");
		}else{
			sums.put(sumKey.toString(),"sum({key})");
		}
		
		List<Map> list = getUserAddressDao().getUserAddressStats(params,groups,sums);
		
		List<Map> result = new ArrayList();
		for(Map m:list){
			Map map = new HashMap();
			Object value = m.get(sumKey.toString());
			Object name = null;
			Object groupValue = m.get(groupKey.toString());
			if(dateType>0){
				name = Utils.date(Utils.parseDate(groupValue), dateFormats[dateType][1]);
			}else{
				try{
					java.lang.reflect.Method method = UserAddress.class.getMethod("get"+Utils.ForMat(groupKey.toString())+"$");
					method.setAccessible(true);
					name = method.invoke(UserAddress.fromMap(m));
				}catch(Exception ex){
					ex.printStackTrace();
				}
			}
			map.put("name", name);
			map.put("value", value);
			result.add(map);
		}
		return result;
	}
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static int updateUserAddress(Map set,Map where){
		if(set.isEmpty())throw new RuntimeException("set为空");
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		return getUserAddressDao().updateUserAddressByConfirm(set, where);
	}
	
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void deleteUserAddress(Map where){
		if(where.isEmpty())throw new RuntimeException("where为空");
		where.put("confirm", "1");
		getUserAddressDao().deleteUserAddressByConfirm(where);
	}
	
	/**
	 * 根据条件更新数据
	 * @param set
	 * @param where
	 */
	public static void delete(Long id){
		if(id==null)throw new RuntimeException("id为空");
		getUserAddressDao().deleteUserAddressById(id);
	}
	
	
	/**
	 * 保存收货地址对象
	 * @param params
	 * @return
	 */
	public UserAddress save(){
		if(this.getId()!=null)
			getUserAddressDao().updateUserAddress(this);
		else
			return getUserAddressDao().saveUserAddress(this);
		return this;
	}
	
	
	/**
	 * 更新收货地址对象的非空字段,注意跟Service里面的update不一样哦
	 * @param params
	 * @return
	 */
	public int update(){
		return getUserAddressDao().updateUserAddress$NotNull(this);
	}
	
	
	/**
	 * 删除
	 * @param params
	 * @return
	 */
	public void delete(){
			getUserAddressDao().deleteUserAddressById(this.getId());
	}
	
	/**
	 * 执行事务
	 * @param function
	 */
	public static <T> T execute(Function function){
		return getUserAddressDao().executeTransaction(function);
	}
	/*******************************编号**********************************/	
	/**
	* 编号 [非空]      
	**/
	public Long getId(){
		if(this.id!=null){
			return this.id;
		}
		return this.id;
	}
	/**
	* 获取编号格式化(toString)
	**/
	public String getId$(){
		String strValue="";
		 strValue=Utils.string(this.getId());
	 	 return strValue;
	}
	/**
	* 根据编号反格式化
	**/
	public void setId$(String strValue){
		if(Utils.empty(strValue)){
			this.id=null;
			return;
		}
	 	this.id=Utils.parseLong(strValue);
	}
	
	/**
	* 编号 [非空]      
	**/
	public void setId(Long id){
		this.id = id;
		this.setSeted(F.id);
	}
	
	
	
	
	/*******************************会员信息**********************************/	
	/**
	* 会员信息  [Member]     
	**/
	public Long getMember(){
		if(this.member!=null){
			return this.member;
		}
		return this.member;
	}
	/**
	* 获取会员信息格式化(toString)
	**/
	public String getMember$(){
		String strValue="";
		if(this.getMember()!=null){
				strValue+=Utils.string(Member.getKeyValue(this.getMember()));
		}			
	 	 return strValue;
	}
	/**
	* 根据会员信息反格式化
	**/
	public void setMember$(String strValue){
		if(Utils.empty(strValue)){
			this.member=null;
			return;
		}
		Member item = Member.find(strValue);
		if(item!=null){
			this.member = Utils.parseLong(item.getId());
		}
	}
	
	/**
	* 会员信息  [Member]     
	**/
	public void setMember(Long member){
		this.member = member;
		this.setSeted(F.member);
	}
	
	
	
	
	/**
	* 获取关联对象[会员信息]
	**/	 			
 	public Member get$member(){
 		if(this.$member!=null)
 			return this.$member;
 		com.distribute.framework.model.Member member = null;
		if(this.getMember()!=null){
 			member = Member.get(this.getMember());
 		}
 		return member;
	}
	/*******************************电话号码**********************************/	
	/**
	* 电话号码       
	**/
	public String getMobile(){
		if(this.mobile!=null){
			return this.mobile;
		}
		return this.mobile;
	}
	/**
	* 获取电话号码格式化(toString)
	**/
	public String getMobile$(){
		String strValue="";
		 strValue=Utils.string(this.getMobile());
	 	 return strValue;
	}
	/**
	* 根据电话号码反格式化
	**/
	public void setMobile$(String strValue){
		if(Utils.empty(strValue)){
			this.mobile=null;
			return;
		}
	 	this.mobile=strValue;
	}
	
	/**
	* 电话号码       
	**/
	public void setMobile(String mobile){
		this.mobile = mobile;
		this.setSeted(F.mobile);
	}
	
	
	
	
	/*******************************收货姓名**********************************/	
	/**
	* 收货姓名       
	**/
	public String getRealName(){
		if(this.realName!=null){
			return this.realName;
		}
		return this.realName;
	}
	/**
	* 获取收货姓名格式化(toString)
	**/
	public String getRealName$(){
		String strValue="";
		 strValue=Utils.string(this.getRealName());
	 	 return strValue;
	}
	/**
	* 根据收货姓名反格式化
	**/
	public void setRealName$(String strValue){
		if(Utils.empty(strValue)){
			this.realName=null;
			return;
		}
	 	this.realName=strValue;
	}
	
	/**
	* 收货姓名       
	**/
	public void setRealName(String realName){
		this.realName = realName;
		this.setSeted(F.realName);
	}
	
	
	
	
	/*******************************性别**********************************/	
	/**
	* 性别    1:男 2:女    
	**/
	public Short getSex(){
		if(this.sex!=null){
			return this.sex;
		}
		return this.sex;
	}
	/**
	* 获取性别格式化(toString)
	**/
	public String getSex$(){
		String strValue="";
		 if(Utils.equals(Utils.string(this.getSex()),"1"))
			strValue=Utils.string("男");		 
		 if(Utils.equals(Utils.string(this.getSex()),"2"))
			strValue=Utils.string("女");		 
	 	 return strValue;
	}
	/**
	* 根据性别反格式化
	**/
	public void setSex$(String strValue){
		if(Utils.empty(strValue)){
			this.sex=null;
			return;
		}
		 if(Utils.equals(strValue,"男"))
		 	this.sex=Utils.parseShort("1");
		 if(Utils.equals(strValue,"女"))
		 	this.sex=Utils.parseShort("2");
	}
	
	/**
	* 性别    1:男 2:女    
	**/
	public void setSex(Short sex){
		this.sex = sex;
		this.setSeted(F.sex);
	}
	
	
	
	
	/*******************************默认**********************************/	
	/**
	* 默认    0:否 1:默认    
	**/
	public Short getIsDefault(){
		if(this.isDefault!=null){
			return this.isDefault;
		}
		return this.isDefault;
	}
	/**
	* 获取默认格式化(toString)
	**/
	public String getIsDefault$(){
		String strValue="";
		 strValue=Utils.string(this.getIsDefault());
	 	 return strValue;
	}
	/**
	* 根据默认反格式化
	**/
	public void setIsDefault$(String strValue){
		if(Utils.empty(strValue)){
			this.isDefault=null;
			return;
		}
	 	this.isDefault=Utils.parseShort(strValue);
	}
	
	/**
	* 默认    0:否 1:默认    
	**/
	public void setIsDefault(Short isDefault){
		this.isDefault = isDefault;
		this.setSeted(F.isDefault);
	}
	
	
	
	
	/*******************************地址**********************************/	
	/**
	* 地址  [Region]     
	**/
	public Long getAddress(){
		if(this.address!=null){
			return this.address;
		}
		return this.address;
	}
	/**
	* 获取地址格式化(toString)
	**/
	public String getAddress$(){
		String strValue="";
		if(this.getAddress()!=null){
				strValue+=Utils.string(Region.getKeyValue(this.getAddress()));
		}			
	 	 return strValue;
	}
	/**
	* 根据地址反格式化
	**/
	public void setAddress$(String strValue){
		if(Utils.empty(strValue)){
			this.address=null;
			return;
		}
		Region item = Region.find(strValue);
		if(item!=null){
			this.address = Utils.parseLong(item.getId());
		}
	}
	
	/**
	* 地址  [Region]     
	**/
	public void setAddress(Long address){
		this.address = address;
		this.setSeted(F.address);
	}
	
	
	
	
	/**
	* 获取关联对象[省市地区]
	**/	 			
 	public Region get$address(){
 		if(this.$address!=null)
 			return this.$address;
 		com.distribute.framework.model.Region region = null;
		if(this.getAddress()!=null){
 			region = Region.get(this.getAddress());
 		}
 		return region;
	}
	/*******************************详细地址**********************************/	
	/**
	* 详细地址       
	**/
	public String getDetailAddress(){
		if(this.detailAddress!=null){
			return this.detailAddress;
		}
		return this.detailAddress;
	}
	/**
	* 获取详细地址格式化(toString)
	**/
	public String getDetailAddress$(){
		String strValue="";
		 strValue=Utils.string(this.getDetailAddress());
	 	 return strValue;
	}
	/**
	* 根据详细地址反格式化
	**/
	public void setDetailAddress$(String strValue){
		if(Utils.empty(strValue)){
			this.detailAddress=null;
			return;
		}
	 	this.detailAddress=strValue;
	}
	
	/**
	* 详细地址       
	**/
	public void setDetailAddress(String detailAddress){
		this.detailAddress = detailAddress;
		this.setSeted(F.detailAddress);
	}
	
	
	
	
	/*******************************所属城市**********************************/	
	/**
	* 所属城市  [Region]     
	**/
	public Long getCityOrigin(){
		if(this.cityOrigin!=null){
			return this.cityOrigin;
		}
		return this.cityOrigin;
	}
	/**
	* 获取所属城市格式化(toString)
	**/
	public String getCityOrigin$(){
		String strValue="";
		if(this.getCityOrigin()!=null){
				strValue+=Utils.string(Region.getKeyValue(this.getCityOrigin()));
		}			
	 	 return strValue;
	}
	/**
	* 根据所属城市反格式化
	**/
	public void setCityOrigin$(String strValue){
		if(Utils.empty(strValue)){
			this.cityOrigin=null;
			return;
		}
		Region item = Region.find(strValue);
		if(item!=null){
			this.cityOrigin = Utils.parseLong(item.getId());
		}
	}
	
	/**
	* 所属城市  [Region]     
	**/
	public void setCityOrigin(Long cityOrigin){
		this.cityOrigin = cityOrigin;
		this.setSeted(F.cityOrigin);
	}
	
	
	
	
	/**
	* 获取关联对象[省市地区]
	**/	 			
 	public Region get$cityOrigin(){
 		if(this.$cityOrigin!=null)
 			return this.$cityOrigin;
 		com.distribute.framework.model.Region region = null;
		if(this.getCityOrigin()!=null){
 			region = Region.get(this.getCityOrigin());
 		}
 		return region;
	}
	/*******************************地址全称**********************************/	
	/**
	* 地址全称       
	**/
	public String getFullAddress(){
		if(this.fullAddress!=null){
			return this.fullAddress;
		}
		return this.fullAddress;
	}
	/**
	* 获取地址全称格式化(toString)
	**/
	public String getFullAddress$(){
		String strValue="";
		 strValue=Utils.string(this.getFullAddress());
	 	 return strValue;
	}
	/**
	* 根据地址全称反格式化
	**/
	public void setFullAddress$(String strValue){
		if(Utils.empty(strValue)){
			this.fullAddress=null;
			return;
		}
		this.fullAddress=strValue;
	}
	
	/**
	* 地址全称       
	**/
	public void setFullAddress(String fullAddress){
		this.fullAddress = fullAddress;
		this.setSeted(F.fullAddress);
	}
	
	
	
	
	/*******************************经度**********************************/	
	/**
	* 经度       
	**/
	public String getLongitude(){
		if(this.longitude!=null){
			return this.longitude;
		}
		return this.longitude;
	}
	/**
	* 获取经度格式化(toString)
	**/
	public String getLongitude$(){
		String strValue="";
		 strValue=Utils.string(this.getLongitude());
	 	 return strValue;
	}
	/**
	* 根据经度反格式化
	**/
	public void setLongitude$(String strValue){
		if(Utils.empty(strValue)){
			this.longitude=null;
			return;
		}
	 	this.longitude=strValue;
	}
	
	/**
	* 经度       
	**/
	public void setLongitude(String longitude){
		this.longitude = longitude;
		this.setSeted(F.longitude);
	}
	
	
	
	
	/*******************************纬度**********************************/	
	/**
	* 纬度       
	**/
	public String getLatitude(){
		if(this.latitude!=null){
			return this.latitude;
		}
		return this.latitude;
	}
	/**
	* 获取纬度格式化(toString)
	**/
	public String getLatitude$(){
		String strValue="";
		 strValue=Utils.string(this.getLatitude());
	 	 return strValue;
	}
	/**
	* 根据纬度反格式化
	**/
	public void setLatitude$(String strValue){
		if(Utils.empty(strValue)){
			this.latitude=null;
			return;
		}
	 	this.latitude=strValue;
	}
	
	/**
	* 纬度       
	**/
	public void setLatitude(String latitude){
		this.latitude = latitude;
		this.setSeted(F.latitude);
	}
	
	
	
	
	/*******************************坐标地址**********************************/	
	/**
	* 坐标地址       
	**/
	public String getCoordinate(){
		if(this.coordinate!=null){
			return this.coordinate;
		}
		return this.coordinate;
	}
	/**
	* 获取坐标地址格式化(toString)
	**/
	public String getCoordinate$(){
		String strValue="";
		 strValue=Utils.string(this.getCoordinate());
	 	 return strValue;
	}
	/**
	* 根据坐标地址反格式化
	**/
	public void setCoordinate$(String strValue){
		if(Utils.empty(strValue)){
			this.coordinate=null;
			return;
		}
	 	this.coordinate=strValue;
	}
	
	/**
	* 坐标地址       
	**/
	public void setCoordinate(String coordinate){
		this.coordinate = coordinate;
		this.setSeted(F.coordinate);
	}
	
	
	
	
	/************LAZY3Q_DEFINE_CODE************/
	/************LAZY3Q_DEFINE_CODE************/
	
	
	/**
	 * 触发器
	 */
	public static void on(Trigger.Index index,final Notify.Listener listener,Trigger.Type... types){
		Notify.on(UserAddress.class, index, listener, types);
	}
	public static void on(final Notify.Listener listener,String type){
		Notify.on(UserAddress.class, listener, type);
	}
	/**
	 * 当修改字段时
	 * @param filedName
	 * @param listener
	 */
	public static void on(String filedName,final Notify.Listener listener){
		Notify.on(UserAddress.class, listener, filedName);
	}
	/**
	 * 当修改字段为某值时
	 * @param filedName
	 * @param value
	 * @param listener
	 */
	public static void on(String filedName,Object value,final Notify.Listener listener){
		if(value==null)return;
		Notify.on(UserAddress.class, listener, filedName+"."+Utils.md5(""+value));
	}
	public void notify(String type){
		Trigger.on(UserAddress.class,type, this);
	}
	
	
	/**
	 * 用来获取当有字段关联对象时的获取方式,调用如${UserAddress.obj.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${UserAddress.$filedName}获取关联对象
	 */
	public Map getObj(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return UserAddress.class.getMethod("get$"+Utils.forMat(key.toString())).invoke(UserAddress.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 用来获取某字段格式化的获取方式,调用如${UserAddress.fmt.filedName}
	 * 因为有些变态的模板语言不能识别$，所以不能以${UserAddress.filedName$}获取某字段格式化
	 */
	public Map getFmt(){
		return new HashMap(){
			@Override
			public Object get(Object key) {
				try {
					return UserAddress.class.getMethod("get"+Utils.ForMat(key.toString()+"$")).invoke(UserAddress.this);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return null;
			}
		};
	}
	/**
	 * 获取查询参数链式串
	 * @return
	 */
	public static @Deprecated M where(){ return new M(0); }
	public static @Deprecated M m(){ return new M(0); }
	public static M where = new M(0,true);
	public static @database(DatabaseNames.distribute_sys) class M extends IbatisMap{
		int type = 0; 
		M linked = null;
		Boolean proxy = false;
		public M set = null;
		public M(int type){
			this.type = type;
			if(this.type==0){
				set = new M(1,true);
				set.linked = this;
			}
		};
		public M(int type,Boolean proxy){
			this.type = type;
			this.proxy=proxy;
		};
		public M proxy(){
			M m = new M(this.type);//当前的对像
			if(this.type==0){
				m.set = new M(1,true);//set对象
				m.set.linked = m;
			}else{
				m.linked=this.linked;
				this.linked.linked=m;
			}
			return m;
		}
		public @Deprecated M set(){			
			M m = this;
			m.linked=new M(1);
			m.linked.linked=m;
			return m.linked;
		};
		public M on(IbatisMap value,C column,String joinColumn){if(proxy)return proxy().on(value,column,joinColumn);this.put(value.getClass().getDeclaringClass().getSimpleName(), value);value.put("on", column.toString());value.put("to", joinColumn);return this;};
		/** 编号 [非空]       **/
		public M id(Object id){if(proxy)return proxy().id(id);  this.put("id", id);return this;};
	 	/** and id is null */
 		public M idNull(){if(proxy)return proxy().idNull();if(this.get("idNot")==null)this.put("idNot", "");this.put("id", null);return this;};
 		/** not .... */
 		public M idNot(){if(proxy)return proxy().idNot();this.put("idNot", "not");return this;};
 		public M idNotNull(){if(proxy)return proxy().idNotNull();this.put("idNot", "not");this.put("id", null);return this;};
 		public M idNot(Object id){if(proxy)return proxy().idNot(id);this.put("idNot", "not");this.put("id", id);return this;};
		/** and id <= ? */
		public M idMin(Object min){if(proxy)return proxy().idMin(min);this.put("idMin", min);return this;};
		/** and id >= ? */
		public M idMax(Object max){if(proxy)return proxy().idMax(max);this.put("idMax", max);return this;};
		public M idIn(String ids){
			if(proxy)return proxy().idIn(ids);  this.put("idIn", ids);return this;
		};	
		public M member$on(Member.M value){if(proxy)return proxy().member$on(value);this.put("Member", value);value.put("on", "member");return this;};
		/** 会员信息  [Member]      **/
		public M member(Object member){if(proxy)return proxy().member(member);  this.put("member", member);return this;};
	 	/** and member is null */
 		public M memberNull(){if(proxy)return proxy().memberNull();if(this.get("memberNot")==null)this.put("memberNot", "");this.put("member", null);return this;};
 		/** not .... */
 		public M memberNot(){if(proxy)return proxy().memberNot();this.put("memberNot", "not");return this;};
 		public M memberNotNull(){if(proxy)return proxy().memberNotNull();this.put("memberNot", "not");this.put("member", null);return this;};
 		public M memberNot(Object member){if(proxy)return proxy().memberNot(member);this.put("memberNot", "not");this.put("member", member);return this;};
		public M memberIn(String ids){
			if(proxy)return proxy().memberIn(ids);  this.put("memberIn", ids);return this;
		};	
		/** 电话号码        **/
		public M mobile(Object mobile){if(proxy)return proxy().mobile(mobile);  this.put("mobile", mobile);return this;};
	 	/** and mobile is null */
 		public M mobileNull(){if(proxy)return proxy().mobileNull();if(this.get("mobileNot")==null)this.put("mobileNot", "");this.put("mobile", null);return this;};
 		/** not .... */
 		public M mobileNot(){if(proxy)return proxy().mobileNot();this.put("mobileNot", "not");return this;};
 		public M mobileNotNull(){if(proxy)return proxy().mobileNotNull();this.put("mobileNot", "not");this.put("mobile", null);return this;};
 		public M mobileNot(Object mobile){if(proxy)return proxy().mobileNot(mobile);this.put("mobileNot", "not");this.put("mobile", mobile);return this;};
		/** 收货姓名        **/
		public M realName(Object realName){if(proxy)return proxy().realName(realName);  this.put("realName", realName);return this;};
	 	/** and real_name is null */
 		public M realNameNull(){if(proxy)return proxy().realNameNull();if(this.get("realNameNot")==null)this.put("realNameNot", "");this.put("realName", null);return this;};
 		/** not .... */
 		public M realNameNot(){if(proxy)return proxy().realNameNot();this.put("realNameNot", "not");return this;};
 		public M realNameNotNull(){if(proxy)return proxy().realNameNotNull();this.put("realNameNot", "not");this.put("realName", null);return this;};
 		public M realNameNot(Object realName){if(proxy)return proxy().realNameNot(realName);this.put("realNameNot", "not");this.put("realName", realName);return this;};
		/** 性别    1:男 2:女     **/
		public M sex(Object sex){if(proxy)return proxy().sex(sex);  this.put("sex", sex);return this;};
	 	/** and sex is null */
 		public M sexNull(){if(proxy)return proxy().sexNull();if(this.get("sexNot")==null)this.put("sexNot", "");this.put("sex", null);return this;};
 		/** not .... */
 		public M sexNot(){if(proxy)return proxy().sexNot();this.put("sexNot", "not");return this;};
 		public M sexNotNull(){if(proxy)return proxy().sexNotNull();this.put("sexNot", "not");this.put("sex", null);return this;};
 		public M sexNot(Object sex){if(proxy)return proxy().sexNot(sex);this.put("sexNot", "not");this.put("sex", sex);return this;};
		public M sexIn(String ids){
			if(proxy)return proxy().sexIn(ids);  this.put("sexIn", ids);return this;
		};	
		/** 默认    0:否 1:默认     **/
		public M isDefault(Object isDefault){if(proxy)return proxy().isDefault(isDefault);  this.put("isDefault", isDefault);return this;};
	 	/** and is_default is null */
 		public M isDefaultNull(){if(proxy)return proxy().isDefaultNull();if(this.get("isDefaultNot")==null)this.put("isDefaultNot", "");this.put("isDefault", null);return this;};
 		/** not .... */
 		public M isDefaultNot(){if(proxy)return proxy().isDefaultNot();this.put("isDefaultNot", "not");return this;};
 		public M isDefaultNotNull(){if(proxy)return proxy().isDefaultNotNull();this.put("isDefaultNot", "not");this.put("isDefault", null);return this;};
 		public M isDefaultNot(Object isDefault){if(proxy)return proxy().isDefaultNot(isDefault);this.put("isDefaultNot", "not");this.put("isDefault", isDefault);return this;};
		/** and is_default <= ? */
		public M isDefaultMin(Object min){if(proxy)return proxy().isDefaultMin(min);this.put("isDefaultMin", min);return this;};
		/** and is_default >= ? */
		public M isDefaultMax(Object max){if(proxy)return proxy().isDefaultMax(max);this.put("isDefaultMax", max);return this;};
		public M isDefaultIn(String ids){
			if(proxy)return proxy().isDefaultIn(ids);  this.put("isDefaultIn", ids);return this;
		};	
		public M address$on(Region.M value){if(proxy)return proxy().address$on(value);this.put("Address", value);value.put("on", "address");return this;};
		/** 地址  [Region]      **/
		public M address(Object address){if(proxy)return proxy().address(address);  this.put("address", address);return this;};
	 	/** and address is null */
 		public M addressNull(){if(proxy)return proxy().addressNull();if(this.get("addressNot")==null)this.put("addressNot", "");this.put("address", null);return this;};
 		/** not .... */
 		public M addressNot(){if(proxy)return proxy().addressNot();this.put("addressNot", "not");return this;};
 		public M addressNotNull(){if(proxy)return proxy().addressNotNull();this.put("addressNot", "not");this.put("address", null);return this;};
 		public M addressNot(Object address){if(proxy)return proxy().addressNot(address);this.put("addressNot", "not");this.put("address", address);return this;};
		public M addressIn(String ids){
			if(proxy)return proxy().addressIn(ids);  this.put("addressIn", ids);return this;
		};	
		/** 详细地址        **/
		public M detailAddress(Object detailAddress){if(proxy)return proxy().detailAddress(detailAddress);  this.put("detailAddress", detailAddress);return this;};
	 	/** and detail_address is null */
 		public M detailAddressNull(){if(proxy)return proxy().detailAddressNull();if(this.get("detailAddressNot")==null)this.put("detailAddressNot", "");this.put("detailAddress", null);return this;};
 		/** not .... */
 		public M detailAddressNot(){if(proxy)return proxy().detailAddressNot();this.put("detailAddressNot", "not");return this;};
 		public M detailAddressNotNull(){if(proxy)return proxy().detailAddressNotNull();this.put("detailAddressNot", "not");this.put("detailAddress", null);return this;};
 		public M detailAddressNot(Object detailAddress){if(proxy)return proxy().detailAddressNot(detailAddress);this.put("detailAddressNot", "not");this.put("detailAddress", detailAddress);return this;};
		public M cityOrigin$on(Region.M value){if(proxy)return proxy().cityOrigin$on(value);this.put("CityOrigin", value);value.put("on", "city_origin");return this;};
		/** 所属城市  [Region]      **/
		public M cityOrigin(Object cityOrigin){if(proxy)return proxy().cityOrigin(cityOrigin);  this.put("cityOrigin", cityOrigin);return this;};
	 	/** and city_origin is null */
 		public M cityOriginNull(){if(proxy)return proxy().cityOriginNull();if(this.get("cityOriginNot")==null)this.put("cityOriginNot", "");this.put("cityOrigin", null);return this;};
 		/** not .... */
 		public M cityOriginNot(){if(proxy)return proxy().cityOriginNot();this.put("cityOriginNot", "not");return this;};
 		public M cityOriginNotNull(){if(proxy)return proxy().cityOriginNotNull();this.put("cityOriginNot", "not");this.put("cityOrigin", null);return this;};
 		public M cityOriginNot(Object cityOrigin){if(proxy)return proxy().cityOriginNot(cityOrigin);this.put("cityOriginNot", "not");this.put("cityOrigin", cityOrigin);return this;};
		public M cityOriginIn(String ids){
			if(proxy)return proxy().cityOriginIn(ids);  this.put("cityOriginIn", ids);return this;
		};	
		/** 地址全称        **/
		public M fullAddress(Object fullAddress){if(proxy)return proxy().fullAddress(fullAddress);  this.put("fullAddress", fullAddress);return this;};
	 	/** and full_address is null */
 		public M fullAddressNull(){if(proxy)return proxy().fullAddressNull();if(this.get("fullAddressNot")==null)this.put("fullAddressNot", "");this.put("fullAddress", null);return this;};
 		/** not .... */
 		public M fullAddressNot(){if(proxy)return proxy().fullAddressNot();this.put("fullAddressNot", "not");return this;};
 		public M fullAddressNotNull(){if(proxy)return proxy().fullAddressNotNull();this.put("fullAddressNot", "not");this.put("fullAddress", null);return this;};
 		public M fullAddressNot(Object fullAddress){if(proxy)return proxy().fullAddressNot(fullAddress);this.put("fullAddressNot", "not");this.put("fullAddress", fullAddress);return this;};
		/** 经度        **/
		public M longitude(Object longitude){if(proxy)return proxy().longitude(longitude);  this.put("longitude", longitude);return this;};
	 	/** and longitude is null */
 		public M longitudeNull(){if(proxy)return proxy().longitudeNull();if(this.get("longitudeNot")==null)this.put("longitudeNot", "");this.put("longitude", null);return this;};
 		/** not .... */
 		public M longitudeNot(){if(proxy)return proxy().longitudeNot();this.put("longitudeNot", "not");return this;};
 		public M longitudeNotNull(){if(proxy)return proxy().longitudeNotNull();this.put("longitudeNot", "not");this.put("longitude", null);return this;};
 		public M longitudeNot(Object longitude){if(proxy)return proxy().longitudeNot(longitude);this.put("longitudeNot", "not");this.put("longitude", longitude);return this;};
		/** 纬度        **/
		public M latitude(Object latitude){if(proxy)return proxy().latitude(latitude);  this.put("latitude", latitude);return this;};
	 	/** and latitude is null */
 		public M latitudeNull(){if(proxy)return proxy().latitudeNull();if(this.get("latitudeNot")==null)this.put("latitudeNot", "");this.put("latitude", null);return this;};
 		/** not .... */
 		public M latitudeNot(){if(proxy)return proxy().latitudeNot();this.put("latitudeNot", "not");return this;};
 		public M latitudeNotNull(){if(proxy)return proxy().latitudeNotNull();this.put("latitudeNot", "not");this.put("latitude", null);return this;};
 		public M latitudeNot(Object latitude){if(proxy)return proxy().latitudeNot(latitude);this.put("latitudeNot", "not");this.put("latitude", latitude);return this;};
		/** 坐标地址        **/
		public M coordinate(Object coordinate){if(proxy)return proxy().coordinate(coordinate);  this.put("coordinate", coordinate);return this;};
	 	/** and coordinate is null */
 		public M coordinateNull(){if(proxy)return proxy().coordinateNull();if(this.get("coordinateNot")==null)this.put("coordinateNot", "");this.put("coordinate", null);return this;};
 		/** not .... */
 		public M coordinateNot(){if(proxy)return proxy().coordinateNot();this.put("coordinateNot", "not");return this;};
 		public M coordinateNotNull(){if(proxy)return proxy().coordinateNotNull();this.put("coordinateNot", "not");this.put("coordinate", null);return this;};
 		public M coordinateNot(Object coordinate){if(proxy)return proxy().coordinateNot(coordinate);this.put("coordinateNot", "not");this.put("coordinate", coordinate);return this;};
	 	public M add(String key, Object value) {if(proxy)return proxy().add(key,value);this.put(key, value);return this;}
	 	public M add(F key, Object value) {if(proxy)return proxy().add(key,value);this.put(key.toString(), value);return this;}
	 	public M desc(C key) {if(proxy)return proxy().desc(key);this.put("desc", key.column);return this;}
	 	public M asc(C key) {if(proxy)return proxy().asc(key);this.put("asc", key.column);return this;}
	 	public M desc(String sql) {if(proxy)return proxy().desc(sql);this.put("desc", sql);return this;}
	 	public M asc(String sql) {if(proxy)return proxy().asc(sql);this.put("asc", sql);return this;}
	 	public M definex(String sql) {if(proxy)return proxy().definex(sql);this.put("definex", sql);return this;}
	 	/** 获取所有收货地址 **/
		public @api List<UserAddress> list(Integer size){			
			return getUserAddressList(this,size);
		}
		/** 获取收货地址分页 **/
		public @api Page<UserAddress> page(Integer page,Integer size){			
			return getUserAddressPage(page, size , this);
		}
		/** 根据查询条件取收货地址 **/
		public @api UserAddress get(){			
			return getUserAddress(this);
		}
		/** 获取收货地址数 **/
		public @api Long count(){			
			return getUserAddressCount(this);
		}
		/** 获取收货地址表达式 **/
		public @api <T> T eval(String strEval){			
			return getUserAddressEval(strEval,this);
		}
		/** 获取收货地址统计 **/
		public @api List<Map> stats(C sumKey,C groupKey,int dateType){			
			return getUserAddressStats(this,sumKey,groupKey,dateType);
		}
		/** 获取收货地址统计 **/
		public @api List<Map> stats(C sumKey,C groupKey){			
			return getUserAddressStats(this,sumKey,groupKey,-1);
		}
		/** 根据条件更新 **/
		public @api int update(){			
			M where = null;
			M set = null;
			if(this.type==0){
				if(this.linked==null)throw new RuntimeException("未发set");
				where = this;
				set = this.linked;
			}else{
				if(this.linked==null)throw new RuntimeException("未发where条件");
				set = this;
				where = this.linked;
			}
			return updateUserAddress(set,where);
		}
		/** 根据条件删除 **/
		public @api void delete(){			
			deleteUserAddress(this);
		}
	}
	
	public static class Param extends M{
		public Param(int type) {
			super(type);
		}
		public Param(int type, Boolean proxy) {
			super(type, proxy);
		}
	}
	
	/** 对象的字段描述 **/
	public static class F{
		/** 编号 [非空]       **/
		public final static @type(Long.class)  String id="id";
		/** 会员信息  [Member]      **/
		public final static @type(Long.class)  String member="member";
		/** 电话号码        **/
		public final static @type(String.class)  String mobile="mobile";
		/** 收货姓名        **/
		public final static @type(String.class)  String realName="realName";
		/** 性别    1:男 2:女     **/
		public final static @type(Short.class)  String sex="sex";
		/** 默认    0:否 1:默认     **/
		public final static @type(Short.class)  String isDefault="isDefault";
		/** and is_default >= ? */
		public final static @type(Short.class) String isDefaultMin="isDefaultMin";
		/** and is_default <= ? */
		public final static @type(Short.class) String isDefaultMax="isDefaultMax";
		/** 地址  [Region]      **/
		public final static @type(Long.class)  String address="address";
		/** 详细地址        **/
		public final static @type(String.class)  String detailAddress="detailAddress";
		/** 所属城市  [Region]      **/
		public final static @type(Long.class)  String cityOrigin="cityOrigin";
		/** 地址全称        **/
		public final static @type(String.class) @like String fullAddress="fullAddress";
		/** 经度        **/
		public final static @type(String.class)  String longitude="longitude";
		/** 纬度        **/
		public final static @type(String.class)  String latitude="latitude";
		/** 坐标地址        **/
		public final static @type(String.class)  String coordinate="coordinate";
	 	public static String get(String name){
			try {
				Field field = F.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	/** 对象的数据库字段描述 **/
	public static enum C{
		id("id"),
		member("member"),
		mobile("mobile"),
		realName("real_name"),
		sex("sex"),
		isDefault("is_default"),
		address("address"),
		detailAddress("detail_address"),
		cityOrigin("city_origin"),
		fullAddress("full_address"),
		longitude("longitude"),
		latitude("latitude"),
		coordinate("coordinate"),
		count("count");
		String column;
		C(String column){
			this.column = column;
		}
		public String toString(){
			return this.column;
		}
		public static String get(String name){
			try {
				Field field = C.class.getField(name);
				if(field!=null)
					return field.get(null).toString();
			} catch (Exception e) {
				//e.printStackTrace();
			}
			return null;
		}
	}
	
	
	
	/**
	* 获取收货地址数据
	**/
	public static Object getData(Object param){
		if(param==null)
			return null;
		Object value = null;
		if(param.getClass()==Long.class)
			value = UserAddress.get((Long)param);
		else if(param instanceof java.util.Map){
			java.util.Map params = (Map) param;
			if(params.get("size")==null)
				value = UserAddress.getUserAddress(params);
			else
				value = UserAddress.getUserAddressList(params, (Integer) params.get("size"));
		}else if(param.getClass()==Long.class )
			value =  UserAddress.where().id(param).get();
		else if(!Utils.empty(param.toString()))
			value = UserAddress.get(Long.valueOf(param.toString()));
		return value;
	}
	
	/**对象转json**/
	public Map toJSON(){
		return toJSON(false);
	}
	public Map toJSON(boolean simple){
		Map map = new HashMap();
		map.put("id",this.getId());
		Utils.fms(map,simple?"":"id",this.getId(),this.getId$());
		Utils.fms(map,simple?"":"member",this.getMember(),this.getMember$());
		Utils.fms(map,simple?"":"mobile",this.getMobile(),this.getMobile$());
		Utils.fms(map,simple?"name":"realName",this.getRealName(),this.getRealName$());
		Utils.fms(map,simple?"":"sex",this.getSex(),this.getSex$());
		Utils.fms(map,simple?"default":"isDefault",this.getIsDefault(),this.getIsDefault$());
		Utils.fms(map,simple?"":"address",this.getAddress(),this.getAddress$());
		Utils.fms(map,simple?"address":"detailAddress",this.getDetailAddress(),this.getDetailAddress$());
		Utils.fms(map,simple?"origin":"cityOrigin",this.getCityOrigin(),this.getCityOrigin$());
		Utils.fms(map,simple?"address":"fullAddress",this.getFullAddress(),this.getFullAddress$());
		Utils.fms(map,simple?"":"longitude",this.getLongitude(),this.getLongitude$());
		Utils.fms(map,simple?"":"latitude",this.getLatitude(),this.getLatitude$());
		Utils.fms(map,simple?"":"coordinate",this.getCoordinate(),this.getCoordinate$());
		if(this.suffix!=null)map.put("suffix", this.suffix);
		/************LAZY3Q_DEFINE_TOJSON************/
		/************LAZY3Q_DEFINE_TOJSON************/
		return map;
	}
	/**对象转map**/
	public Map toMap(){
		Map map = new HashMap();
		map.put("id",this.getId());
		map.put("member",this.getMember());
		map.put("mobile",this.getMobile());
		map.put("realName",this.getRealName());
		map.put("sex",this.getSex());
		map.put("isDefault",this.getIsDefault());
		map.put("address",this.getAddress());
		map.put("detailAddress",this.getDetailAddress());
		map.put("cityOrigin",this.getCityOrigin());
		map.put("fullAddress",this.getFullAddress());
		map.put("longitude",this.getLongitude());
		map.put("latitude",this.getLatitude());
		map.put("coordinate",this.getCoordinate());
		map.put("suffix", this.suffix);
		/************LAZY3Q_DEFINE_TOMAP************/
		/************LAZY3Q_DEFINE_TOMAP************/
		return map;
	}
	/**map转对象**/
	public static UserAddress fromMap(Map map){
		UserAddress userAddress = new UserAddress();
		userAddress.id = Utils.parseLong(map.get("id"));
		userAddress.member = Utils.parseLong(map.get("member"));
		userAddress.mobile = Utils.parseString(map.get("mobile"));
		userAddress.realName = Utils.parseString(map.get("realName"));
		userAddress.sex = Utils.parseShort(map.get("sex"));
		userAddress.isDefault = Utils.parseShort(map.get("isDefault"));
		userAddress.address = Utils.parseLong(map.get("address"));
		userAddress.detailAddress = Utils.parseString(map.get("detailAddress"));
		userAddress.cityOrigin = Utils.parseLong(map.get("cityOrigin"));
		userAddress.fullAddress = Utils.parseString(map.get("fullAddress"));
		userAddress.longitude = Utils.parseString(map.get("longitude"));
		userAddress.latitude = Utils.parseString(map.get("latitude"));
		userAddress.coordinate = Utils.parseString(map.get("coordinate"));
		return userAddress;
	}
	
	
	
	/**字段设置标记队列**/
	private Map<String,Boolean> seted=new HashMap();
	public Boolean getSeted(String key){
		return seted.get(key);
	}
	public void setSeted(String key){
		seted.put(key,true);
	}
	/**同步未set的字段**/
	public void mergeSet(UserAddress old){
		Field[] fields = this.getClass().getDeclaredFields();
		try {
			for(Field field:fields){
				String key = field.getName();
				if(seted.get(key)==null && field.getAnnotation(column.class)!=null){
					field.setAccessible(true);
					field.set(this, field.get(old));					
				}
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
	
		
	/**自定义变量存储**/
	private Map values=new HashMap();
	public Map getValues(){
		return values;
	}
	public void setValues(String name,Object value){
		values.put(name,value);
	}
	
	/**分表时的表名后缀**/
	private String suffix;
	public String getSuffix() {
		return suffix;
	}
	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}
	/**获取数据库名称**/
	public static String getDataBaseName(){
		return Utils.config("spring.datasource.distribute_sys.name");
	}
	
	public static String getIcon(){
		return "/images/icons/Identification card.png";
	}
	public static String getIconfont(){
		return "icon-gerenxinxi";
	}
	public static enum ACT{
		列表,添加,修改,详情
	};
	public static String getUrl(ACT act,UserAddress.M params){
		if(params==null)params=new UserAddress.M(0);
		params.remove("joins");
		params.remove("definexs");
		params.remove("distinct");
		String strUrl = "/admin/users/useraddress.edit.html?";
		if(params.get("id")!=null){
			strUrl+="&id="+Utils.encode(""+params.get("id"),Utils.UTF8);
		}
		if(act==ACT.列表){
			strUrl = "/admin/users/useraddress.html?1=1";
		}else if(act==ACT.添加){
			strUrl+="&edittype=insert";
		}else if(act==ACT.修改){
			strUrl+="&edittype=update";
		}else if(act==ACT.详情){
			strUrl+="&edittype=detail";
		}		
		if(params!=null){
			for(Object key:params.keySet()){
				strUrl+="&"+key+"="+Utils.encode(""+params.get(key),Utils.UTF8)+"";
			}
		}
		return strUrl;
	}
	public String getDetailUrl(){
		return this.getUrl(ACT.详情, where.id(this.getId()));
	}
	
	/**
	* 转跳到当前地址
	**/
	public static Protocol redirect(UserAddress.ACT act,UserAddress.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_REDIRECT");
		protocol.set("url",UserAddress.getUrl(act, params));
		return protocol;
	}
	/**
	* 打开一个新的tab页面
	**/
	public static Protocol href(UserAddress.ACT act,UserAddress.M params){
		Protocol protocol = Protocol.create(true,null,"ACT_HREF");
		protocol.set("url",UserAddress.getUrl(act, params));
		protocol.set("title",act.name());
		return protocol;
	}
	/**
	* 显示一个消息框，并且关闭当前的对话框
	**/
	public static Protocol message(String message){
		Protocol protocol = Protocol.create(true,null,"ACT_MESSAGE");
		protocol.set("message",message);
		return protocol;
	}
	
	
	static com.distribute.framework.dao.IUserAddressDao getUserAddressDao(){
		return Utils.getBean("userAddressDao");
	};
	
}